<template>
  <div class="personal">
    <div class="personal_header">
      <div class="header_user" @click="handleGoAccount">
        <div class="header_cover">
          <img :src="userInfo.avatar" alt="">
        </div>
        <div class="header_title">
          {{ userInfo.nickname }}
          <div class="header_date">坚持记账的第{{getRecordDate(userInfo.createTime) }}天</div>
        </div>
      </div>

    </div>
    <div class="personal_grids">
      <div class="grid_item" @click="handleGoPage('/')">
         <i class="iconfont icon-rili" ></i>
        <div class="grid_text">设置</div>
      </div>
      <div class="grid_item" @click="handleGoPage('/')">
         <i class="iconfont icon-icon"></i>
        <div class="grid_text">主题外观</div>
      </div>
      <div class="grid_item" @click="handleGoPage('/bookManage')">
        <i class="iconfont icon-icon-test" ></i>
        <div class="grid_text">账本管理</div>
      </div>
      <div class="grid_item" @click="handleGoPage('/editClass')">
         <i class="iconfont icon-qianbao"></i>
        <div class="grid_text">分类管理</div>
      </div>
      <!-- <div class="grid_item">
         <i class="iconfont icon-tubiao"></i>
        <div class="grid_text">自动记账</div>
      </div>
      <div class="grid_item">
         <i class="iconfont icon-tubiaozhuzhuangtu"></i>
        <div class="grid_text">周期记账</div>
      </div>
      <div class="grid_item">
         <i class="iconfont icon-wode"></i>
        <div class="grid_text">标签管理</div>
      </div>
      <div class="grid_item">
         <i class="iconfont icon-wode1"></i>
        <div class="grid_text">分类关键词</div>
      </div> -->
    </div>
    <!-- <div class="personal_index_bars">
      <div class="index_bar">
        <div class="index_bar_title">数据管理</div>
        <div class="index_bar_list">
          <div class="list_item">
            <div class="list_item_icon">
              <i class="iconfont icon-tubiao"></i>
              <span class="list_item_text">
              云同步
            </span>
            </div>
            <div class="list_item_label" v-if="false"></div>
            <div class="list_item_arrow">
              <i class="iconfont icon-zhankai"></i>
            </div>
          </div>
          <div class="list_item">
            <div class="list_item_icon">
              <i class="iconfont icon-tubiao"></i>
              <span class="list_item_text">
              数据备份
            </span>
            </div>
            <div class="list_item_label" v-if="false"></div>
            <div class="list_item_arrow">
              <i class="iconfont icon-zhankai"></i>
            </div>
          </div>
          <div class="list_item">
            <div class="list_item_icon">
              <i class="iconfont icon-tubiao"></i>
              <span class="list_item_text">
              导入导出
            </span>
            </div>
            <div class="list_item_label" v-if="false"></div>
            <div class="list_item_arrow">
              <i class="iconfont icon-zhankai"></i>
            </div>
          </div>
        </div>
      </div>
    </div> -->
  </div>
</template>

<script lang="ts">
import dayjs from 'dayjs'
import { computed, defineComponent } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
export default defineComponent({
  name: 'Personal',
  setup() {
    const store = useStore()
    const router = useRouter()
    const userInfo = computed(() => store.state.user)
    console.log(userInfo.value, '107');
    const getRecordDate = (createTime: string) => {
      const days = dayjs().diff(createTime, 'day')
      console.log(days, '111')
      return days + 1
    }
    const handleGoPage = (path: string) => {
      router.push(path)
    }
    const handleGoAccount = () => {
      router.push('/account')
    }
    return {
      userInfo,
      handleGoPage,
      getRecordDate,
      handleGoAccount
    }
  }
})
</script>

<style scoped>
  .personal_header {
    background-image: url("../../assets/picture/user.jpeg");
    border-radius: 0 0 40px 40px;
    display: flex;
    height: 150px;
  }
  .header_user {
    margin: 100px 3% 0;
    width: 94%;
    height: 140px;
    position: relative;
    background-color: #fff;
    background-image: url("../../assets/picture/login.jpeg");
    background-size: cover;
    background-position-y: 70%;
    border-radius: 10px;
    box-shadow: #aea3a3 0px -2px 7px 0px;
  }
  .header_cover {
    position: absolute;
    height: 70px;
    width: 70px;
    border-radius: 50%;
    left: 0;
    right: 0;
    top: -35px;
    margin: 0 auto;
    background: green;
  }
  .header_cover img {
    height: 70px;
    width: 70px;
    border-radius: 50%;
  }
  .header_title {
    font-size: 20px;
    font-weight: 600;
    padding: 50px;
  }
  .header_date {
    font-size: 14px;
    line-height: 30px;
  }
  .personal_grids {
    margin: 110px 3% 20px;
    display: flex;
    flex-wrap: wrap;
    padding: 20px 10px 0;
    border-radius: 10px;
    background-color: #f9c3c233;
  }
  .grid_item {
    width: 25%;
    margin-bottom: 20px;
  }
  .iconfont {
    color: #F9C3C2;
    font-size: 20px;
  }
  .grid_text {
    font-size: 14px;
    margin-top: 12px;
  }
  .personal_index_bars {
    margin: 0 3%;
  }
  .index_bar {
    background-color: rgba(249,195,194, 0.2);
    border-radius: 10px;
    padding: 18px;
    text-align: left;
    font-size: 14px;
  }
  .index_bar_list {
    font-size: 18px;
    /* font-weight: 600; */
  }
  .list_item {
    display: flex;
    align-items: center;
    height: 60px;
    justify-content: space-between;
  }
  .list_item_text {
    padding-left: 10px;
    font-size: 16px;
  }
</style>

